package com.example.hosptial.repository;

import com.example.hosptial.model.view.DoctorView;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface DoctorViewRepository extends JpaRepository<DoctorView, String> {

    // 根据科室ID查询
    List<DoctorView> findByDeptId(Integer deptId);

    // 根据医生姓名模糊查询
    List<DoctorView> findByDoctorNameContaining(String doctorName);

    // 根据科室名称查询
    List<DoctorView> findByDeptName(String deptName);

     // 添加登录验证方法
    @Query("SELECT d FROM DoctorView d WHERE d.doctorId = :doctorId AND d.doctorPassword = :password")
    Optional<DoctorView> validateLogin(@Param("doctorId") String doctorId,
                                       @Param("password") String password);

    Optional<DoctorView> findByDoctorId(String doctorId);
}